

let baseUrl = 'https://m1.apifoxmock.com/m1/4728220-0-default'

// if(process.env.NODE_ENV === "development"){
// 	baseUrl = 'http://localhost:5173'
// }else{
// 	baseUrl = 'https://m1.apifoxmock.com/m1/4728220-0-default'
// }

export default function http(url,data={},method='GET'){
	return new Promise((resolve,reject)=>{
		uni.request({
			url:baseUrl +url,
			data,
			header:{
				token:uni.getStorageSync("token")
			},
			method,
			success:res =>{
				if(res.statusCode == 200){
					if(res.data.code == 1){
						resolve(res.data.data)
					}else if(res.data.code == 0){
						uni.showToast({
							icon:'none',
							title:res.data.msg,
						})
						reject(res.data.msg)
					}
				}
			},
			fail:()=>{
				
			}
		})
	})
}